/*
 * @Date: 2025-02-27 16:57:41
 * @LastEditors: 春贰
 * @gitee: https://gitee.com/chun22222222
 * @github: https://github.com/chun222
 * @Desc: 
 * @LastEditTime: 2025-02-27 17:11:03
 */
// logApp.rs
use fern::Dispatch;
use log::LevelFilter;
use std::io;

pub fn log_init() {
    Dispatch::new()
       .format(|out, message, record| {
            out.finish(format_args!(
                "[{}][{}] {}",
                record.level(),
                chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
                message
            ))
        })
       .level(LevelFilter::Debug)
       .chain(io::stdout()) // 同时输出到控制台
       .chain(fern::log_file("app.log").expect("Failed to open log file"))
       .apply()
       .expect("Failed to initialize logger");
}